<template>
  <div>
<!--    <QAItem @deleteqa="deleteQAEvent" :qaname="qaname" :qatime="qatime"></QAItem>-->
<!--    <QAItem :qaname="qaname" :qatime="qatime"></QAItem>-->

    <QAItem v-for="item in data"
            v-show="isShow(item) && (item.isDeleted===false)"
            @deleteqa="deleteQAEvent(item)"
            @stoppublishrefresh="refreshStopPublish"
            @publishrefresh="refreshPublish"
            @duplicateQA="duplicateQA"
            :qaid="item.id"
            :qastatus="item.isPosted"
            :qacount="item.count"
            :qatime="item.createdDate"
            :qaname="item.title"
            :qtype="item.type"></QAItem>
  </div>
</template>

<script>
import QAItem from "@/qaManage/components/mainComponents/QAItem";
export default {
  name: "QAManageMain",
  data() {
    return {
      qaname: 'this is qa name',
      qatime: '20210821',
    }
  },
  computed: {

  },
  props: ['data', 'filterstatus'],
  components:{
    QAItem,
  },
  methods: {
    // 监听来自QAItem的删除
    deleteQAEvent(item) {
      console.log(item);
      // item.isDeleted = true
      console.log(item.id);
      this.$emit('deleteqamain', item)
    },

    // 是否显示的筛选
    isShow(item) {
      if (item.isDeleted === true) {
        return false
      }

      if (this.filterstatus.data === 0) { // 不进行筛选
        return true
      }
      else if (this.filterstatus.data === 1) { // 获取已发布问卷
        if (item.isPosted === true) {
          console.log('选择为已发布问卷');
          return true
        }
        console.log('选择为未发布问卷');
        return false
      }
      else if (this.filterstatus.data === 2) { // 获取未发布问卷
        if (item.isPosted === false) {
          console.log('选择为未发布问卷');
          return true
        }
        console.log('发布问卷');
        return false
      }
    },

    refreshStopPublish(qaid) {
      this.$emit('refreshispostedmain', qaid)
    },

    refreshPublish(qaid) {
      this.$emit('refreshpublishmain', qaid)
    },

    duplicateQA() {
      this.$emit('duplicateQA')
    }


  }
}
</script>

<style scoped>

</style>